package yl.hs.bmipfull.daos.production;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import yl.hs.bmipfull.daos.BaseDao;
import yl.hs.bmipfull.pojo.production.ProductionRecordDetailsEntity;
import yl.hs.bmipfull.viewmodels.production.ProductionRecordDetailSO;
import yl.hs.bmipfull.viewmodels.production.ProductionRecordDetailsVO;
import yl.hs.bmipfull.viewmodels.statistics.DailyProductionCostStatistics;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 *  @apiNote  生产记录表持久层接口
 * @since 2021年10月26日 14时21分54秒
 * @author 张凯
 */
@Repository
public interface IProductionRecordDetailsDao extends BaseDao<ProductionRecordDetailsEntity>{

        /**
         * 查询生产原材消耗明细信息
         * @return 原材消耗明细
         */
        List<ProductionRecordDetailsEntity> FindMaxByRecordId(@Param("id")Long id,@Param("lineSN")String lineSN);

        /**
         * 查询生产原材消耗明细信息
         * @param recordId 消耗id
         * @return 原材消耗明细
         */
        List<ProductionRecordDetailsEntity> queryListByRecordId(Long recordId);



        /**
         * 根据消耗信息ID查询库存明细
         * @param idList 消耗信息ID
         * @return 消耗明细
         */
        List<ProductionRecordDetailsVO> queryListByRecordIdList(List<Long> idList);
        /**
         * 根据消耗信息ID查询库存明细
         * @param idList 消耗信息ID
         * @return 消耗明细
         */
        List<ProductionRecordDetailsEntity> queryByRecordIdList(List<Long> idList);

        Integer deleteMaxRecordDetails(@Param("id") Long id,@Param("lineSN")String lineSN);

        List<ProductionRecordDetailsEntity> queryListByTimeAndUnit(@Param("unit") String unit,@Param("start") Date day,@Param("end") Date endTime);
        List<ProductionRecordDetailSO> queryByRecordId(List<Long> allId);

        /**
         * 生产板块管理看板
         *
         * @param companyName
         * @param year
         * @param month
         * @return
         */
        List<DailyProductionCostStatistics> getProductionBoardData(@Param("year") Integer year, @Param("month") Integer month);

        List<Map<String, Object>> monthQuantityAmount(@Param("year")Integer year, @Param("month")Integer month);
        /**
         * 找到本月所消耗原材种类
         *
         * @param year
         * @param month
         * @return
         */
        List<String> findMaterialsByMonth(@Param("year") Integer year, @Param("month") Integer month);
        /**
         * 找到本月所消耗原材种类
         *
         * @param time
         * @return
         */
        List<String> findMaterialsNameGroupByTime(@Param("time") Date time,@Param("unit") String unit);
        /**
         * 根据时间获取产品名称和总方量
         *
         * @param time
         * @return
         */
        List<Map<String, Object>> findProductNameGroupByTime(@Param("time") Date time,@Param("unit") String unit);

        List<Map<String, Object>> findSumConsumptionQuantityGroupByTime(@Param("time") Date time,@Param("unit") String unit);

}